package com.prs.crm.dao.oa.impl;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

import com.prs.crm.dao.impl.BaseDaoImpl;
import com.prs.crm.dao.oa.AnnouncementCollectTypeDao;
import com.prs.crm.domain.oa.AnnouncementCollectType;
import com.prs.crm.domain.oa.NewsCollectType;

public class AnnouncementCollectTypeDaoImpl extends BaseDaoImpl<AnnouncementCollectType> implements AnnouncementCollectTypeDao{

	@Override
	public AnnouncementCollectType getTypeByName(String name) {
		Criteria criteria = this.getSession().createCriteria(AnnouncementCollectType.class);
		criteria.add(Restrictions.eq("name", name));
		List<AnnouncementCollectType> list = criteria.list();
		if(list.size()!=0){
			return list.get(0);
		}else{
			return null;
		}
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<AnnouncementCollectType> getAll() {
		Criteria criteria = this.getSession().createCriteria(AnnouncementCollectType.class);
		return criteria.list();
	}

}
